Skip to content

feat(cookie): update @routup/cookie for routup v5#759

Merged
tada5hi merged 2 commits intomasterfrom
744-cookie
Apr 8, 2026
Merged

feat(cookie): update @routup/cookie for routup v5#759
tada5hi merged 2 commits intomasterfrom
744-cookie

Conversation

@tada5hi
Copy link
Copy Markdown
Contributor

@tada5hi tada5hi commented Apr 8, 2026

closes #744

Summary by CodeRabbit

  • Chores

    • Updated routup dependency to version beta.3 across assets, cookie, and swagger packages.
    • Removed unused test dependencies from the cookie package.
  • Refactor

    • Migrated cookie request and response handling APIs to support event-based request processing.
    • Updated internal utility functions for improved compatibility with new routing architecture.
    • Aligned unit tests with Fetch-style request-response model for consistency.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 8, 2026

Caution

Review failed

An error occurred during the review process. Please try again later.

📝 Walkthrough

Walkthrough

This pull request updates the @routup/cookie and @routup/swagger packages to support routup v5 beta 3, migrating from Express-style (req, res, next) middleware to routup's event-based handler API. Cookie utilities now operate on IRoutupEvent instead of Request and Response objects. Tests are rewritten to use routup's Fetch-style request/response model.

Changes

Cohort / File(s) Summary
Version Bumps
packages/assets/package.json, packages/swagger/package.json
Updated routup peer and dev dependency constraints from ^5.0.0-beta.2 to ^5.0.0-beta.3.
Cookie Package Configuration
packages/cookie/package.json
Upgraded routup peer dependency from ^4.0.1 to ^5.0.0-beta.3; removed supertest and @types/supertest from dev dependencies; updated dev routup to match peer.
Cookie Handler Migration
packages/cookie/src/handler.ts
Refactored createHandler to return a handler via defineCoreHandler instead of coreHandler. Changed from (req, res, next) middleware callback to event-based handler that reads/writes cookies via event and returns event.next().
Cookie Request Utilities
packages/cookie/src/request.ts
Updated all request cookie helpers (useRequestCookies, hasRequestCookies, useRequestCookie, setRequestCookies) to accept IRoutupEvent instead of Request and access cookies via event.store[CookieSymbol].
Cookie Response Utilities
packages/cookie/src/response.ts
Changed setResponseCookie and unsetResponseCookie to accept IRoutupEvent instead of Response; now use appendResponseHeader(event, 'set-cookie', ...) for header manipulation.
Cookie Parsing Utility
packages/cookie/src/utils.ts
Updated parseRequestCookies to accept IRoutupEvent and read cookie headers via event.headers.get('cookie') instead of req.headers[HeaderName.COOKIE].
Cookie Unit Tests
packages/cookie/test/unit/module.spec.ts
Rewrote tests from supertest/Node-style HTTP to routup v5 Fetch-style. Route handlers now use defineCoreHandler((event) => ...) with direct return values; test requests constructed with Request objects and cookie headers; assertions updated to use Fetch API properties.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Router as `@routup/router`
    participant Handler as defineCoreHandler
    participant Middleware as Cookie Handler
    participant Next as event.next()

    Client->>Router: fetch(Request with cookie header)
    Router->>Handler: event-based handler execution
    Handler->>Middleware: createHandler(event)
    Middleware->>Middleware: hasRequestCookies(event)?
    alt Cookies Present
        Middleware->>Middleware: useRequestCookies(event)
        Middleware->>Next: event.next()
    else Cookies Absent
        Middleware->>Middleware: parseRequestCookies(event)
        Middleware->>Middleware: setRequestCookies(event, parsed)
        Middleware->>Next: event.next()
    end
    Next-->>Handler: Response
    Handler-->>Router: Response
    Router-->>Client: HTTP Response with set-cookie headers
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • feat: update @routup/cookie for routup v5 #744: This PR directly fulfills the objectives of the linked issue to update @routup/cookie for routup v5, including updating peer dependencies, rewriting handlers to event-based API, and updating tests.
  • feat: update @routup/decorators for routup v5 #745, #746, #747, #748, #749, #750, #742: Related routup v5 migration PRs following the same pattern of converting (req, res, next) middleware to event-based handlers and migrating Request/Response helpers to IRoutupEvent equivalents.

Possibly related PRs

Poem

🐰 Hopping through handlers, event by event,
From req and res, now forward we went,
Cookies stored in event.store so neat,
v5's sweet fetch-style flow, complete! 🍪✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main objective of the pull request - updating the @routup/cookie package for routup v5 compatibility.
Linked Issues check ✅ Passed All coding requirements from issue #744 are met: dependencies updated to ^5.0.0-beta.3, handlers rewritten to event-based API, internal calls updated, and tests migrated to new Fetch-style routing.
Out of Scope Changes check ✅ Passed All changes are directly related to updating @routup/cookie for routup v5 compatibility as specified in issue #744; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 744-cookie

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/cookie/package.json`:
- Around line 54-60: The package's public API has a breaking change (cookie API
migrated to IRoutupEvent and dependency bumped to routup ^5.0.0-beta.3) but the
package.json "version" field still reflects the old major; update the "version"
field in package.json to a new major (e.g., 3.0.0) to follow semver, and update
any release notes/CHANGELOG entry to document the breaking change referencing
IRoutupEvent and the routup v5 migration so consumers are aware; also verify and
adjust any peerDependencies or compatibility notes related to "routup" if
present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1d828175-1c36-430e-ba12-3ac645a15654

📥 Commits

Reviewing files that changed from the base of the PR and between f14e23a and fdb79d2.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (8)
  • packages/assets/package.json
  • packages/cookie/package.json
  • packages/cookie/src/handler.ts
  • packages/cookie/src/request.ts
  • packages/cookie/src/response.ts
  • packages/cookie/src/utils.ts
  • packages/cookie/test/unit/module.spec.ts
  • packages/swagger/package.json

Comment on lines +54 to +60
"routup": "^5.0.0-beta.3"
},
"dependencies": {
"cookie-es": "^3.1.1"
},
"devDependencies": {
"@types/supertest": "^7.2.0",
"routup": "^4.0.1",
"supertest": "^7.1.4"
"routup": "^5.0.0-beta.3"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Missing major version bump for a breaking API migration.

With routup moved to ^5.0.0-beta.3 and the cookie API migrated to IRoutupEvent, keeping package version 2.4.3 (Line 3) can violate semver expectations for consumers.

🔧 Proposed package version bump
-    "version": "2.4.3",
+    "version": "3.0.0",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cookie/package.json` around lines 54 - 60, The package's public API
has a breaking change (cookie API migrated to IRoutupEvent and dependency bumped
to routup ^5.0.0-beta.3) but the package.json "version" field still reflects the
old major; update the "version" field in package.json to a new major (e.g.,
3.0.0) to follow semver, and update any release notes/CHANGELOG entry to
document the breaking change referencing IRoutupEvent and the routup v5
migration so consumers are aware; also verify and adjust any peerDependencies or
compatibility notes related to "routup" if present.

@tada5hi tada5hi merged commit 190178f into master Apr 8, 2026
4 of 5 checks passed
@github-actions github-actions Bot mentioned this pull request Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: update @routup/cookie for routup v5

1 participant